package com.lingjtx.common.security.interceptor;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.lingjtx.common.core.token.UserVo;

/**
 * 用户信息上下文传递
 */
public class UserContext {

//    private static final ThreadLocal<UserVo> USER_THREAD_LOCAL = new ThreadLocal<>();
    private static final TransmittableThreadLocal<UserVo> USER_THREAD_LOCAL = new TransmittableThreadLocal<>();

    public static void setUser(UserVo user) {
        USER_THREAD_LOCAL.set(user);
    }

    public static UserVo getUser() {
        return USER_THREAD_LOCAL.get();
    }

    public static void clear() {
        USER_THREAD_LOCAL.remove();
    }
}
